def is_subsequence(seq1, seq2):
    last_hit = 0
    memo = []
    for item in range(len(seq2)):  # n
        for jtem in range(len(seq1)):  # m
            if jtem + last_hit >= len(seq1):
                break
            if seq2[item] == seq1[jtem + last_hit] and item <= jtem + last_hit:
                last_hit = jtem + last_hit
                memo.append(seq2[item])
                break
    return memo == seq2


def is_subsequence_verbose(seq1, seq2):
    """This doesn't need the if-else conditionals at the beginning anymore."""
    if seq1 == seq2:
        return True
    elif len(seq1) < len(seq2):
        return False
    else:
        return is_subsequence(seq1, seq2)


def is_subsequence_buggy(seq1, seq2):
    """This one only counts the size. Also it doesn't work as-is."""
    n = len(seq1)  # need to add a check for n within the loop
    m = len(seq2)
    cntr = 0
    jtem = 0  # 1 for 1-index, 0 for 0-offset
    for item in range(m):
        if jtem <= m and item < n and seq1[item] == seq2[jtem]:
            cntr = cntr + 1
            jtem = jtem + 1
    return cntr == m


def is_subsequence_p(A, B):
    """
    :type A: List[int]
    :type B: List[int]
    :rtype: bool
    """
    n = len(A)
    m = len(B)
    # Create a DP table to store results of subproblems.
    # dp[i][j] = True if the first i elements of B is a subsequence of the first j elements of A.
    dp = [[False] * (m + 1) for _ in range(n + 1)]
    # Base cases: an empty subsequence is a subsequence of any array
    for i in range(n + 1):
        dp[i][0] = True
        # Build the DP table bottom-up
    for i in range(1, n + 1):
        for j in range(1, m + 1):
            # If the last element of B is in A, then the subsequence can be formed
            # by including the last element of B or excluding it.
            if B[j - 1] == A[i - 1]:
                dp[i][j] = dp[i - 1][j - 1] or dp[i - 1][j]
            # If the last element of B is not in A, then the subsequence can only be formed
            # by excluding the last element of B.
            else:
                dp[i][j] = dp[i - 1][j]

    # Return the result stored in the bottom right corner of the DP table
    return dp[n][m]
